
log using comparisons, replace

use "GSS_2006_2020RecodedAppendedPanels.dta"

generate wavefe = yearintv

xtset panel_id yearintv, delta(2)







/**Interclass correlation coefficients*/

	/*Ideological Identification*/

icc polviews panel_id yearintv if panel== 1,mixed absolute

icc polviews panel_id yearintv if panel== 2,mixed absolute

icc polviews panel_id yearintv if panel== 3,mixed absolute

/* cannot compute because no case (individual) observed in all waves of panel 4
icc polviews panel_id yearintv if panel== 4,mixed absolute
*/




	/*Government spending too much, too little, or about the right amount on military, armaments and defense.*/

icc rec_natarms panel_id yearintv if panel== 1,mixed absolute

icc rec_natarms panel_id yearintv if panel== 2,mixed absolute

icc rec_natarms panel_id yearintv if panel== 3,mixed absolute

/* cannot compute because no case (individual) observed in all waves of panel 4

icc rec_natarms panel_id yearintv if panel== 4,mixed absolute
*/



	/*Government spending too much, too little, or about the right amount on welfare.*/
icc rec_natfare panel_id yearintv if panel== 1,mixed absolute

icc rec_natfare panel_id yearintv if panel== 2,mixed absolute

icc rec_natfare panel_id yearintv if panel== 3,mixed absolute

/* cannot compute because no case (individual) observed in all waves of panel 4

icc rec_natfare panel_id yearintv if panel== 4,mixed absolute
*/



	/*Government spending too much, too little, or about the right amount on improving and protecting the environment.*/
icc rec_natenvir panel_id yearintv if panel== 1,mixed absolute

icc rec_natenvir panel_id yearintv if panel== 2,mixed absolute

icc rec_natenvir panel_id yearintv if panel== 3,mixed absolute

/* cannot compute because no case (individual) observed in all waves of panel 4

icc rec_rec_natenvir panel_id yearintv if panel== 4,mixed absolute
*/




	/*The number of immigrants to America nowadays should be reduced a lot, reduced a little, remain the same as it is, increased a little, or increased a lot*/
icc rec_letin1a panel_id yearintv if panel== 1,mixed absolute

icc rec_letin1a panel_id yearintv if panel== 2,mixed absolute

icc rec_letin1a panel_id yearintv if panel== 3,mixed absolute

/* cannot compute because no case (individual) observed in all waves of panel 4

icc rec_letin1a panel_id yearintv if panel== 4,mixed absolute
*/



	/* Party Identification*/
icc rec_partyid panel_id yearintv if panel== 1,mixed absolute

icc rec_partyid panel_id yearintv if panel== 2,mixed absolute

icc rec_partyid panel_id yearintv if panel== 3,mixed absolute

/* cannot compute because no case (individual) observed in all waves of panel 4

icc rec_partyid panel_id yearintv if panel== 4,mixed absolute

*/






/**AR1 approach**/

	/*Party Identification*/
eststo:  xtregar rec_partyid age ib3.degree ib1.race ib1.sex ib1.rec_income ib1.panel i.wavefe, re  
estimates store rec_partyidar1


	/*Ideological Identification*/
eststo:  xtregar polviews age ib3.degree ib1.race ib1.sex ib1.rec_income ib1.panel i.wavefe, re  
estimates store polviewsar1

	/*Government spending too much, too little, or about the right amount on military, armaments and defense.*/
eststo:  xtregar rec_natarms age ib3.degree ib1.race ib1.sex ib1.rec_income ib1.panel i.wavefe, re  
estimates store rec_natarmsar1

	/*Government spending too much, too little, or about the right amount on welfare.*/
eststo:  xtregar rec_natfare age ib3.degree ib1.race ib1.sex ib1.rec_income ib1.panel i.wavefe, re  
estimates store rec_natfarear1

	/*Government spending too much, too little, or about the right amount on improving and protecting the environment.*/
eststo:  xtregar rec_natenvir age ib3.degree ib1.race ib1.sex ib1.rec_income ib1.panel i.wavefe, re  
estimates store rec_natenvirar1

	/*The number of immigrants to America nowadays should be reduced a lot, reduced a little, remain the same as it is, increased a little, or increased a lot*/
eststo:  xtregar rec_letin1a  age ib3.degree ib1.race ib1.sex ib1.rec_income ib1.panel i.wavefe, re  
estimates store rec_letin1aar1 

/*combine estimates from six models into one table for paper*/
esttab rec_partyidar1 polviewsar1 rec_natarmsar1 rec_natfarear1 rec_natenvirar1 rec_letin1aar1  using gssar1.csv, replace se stat(rho_ar sigma_u sigma_e rho_fov N N_g) star(* 0.10 ** 0.05 *** 0.01) t(3) b(3)






/*Arellano-Bond linear dynamic panel-data estimation approach*/

/*cannot compute because artests() exceed the number of time periods*/
//Error: Equation not identified. Regessors outnumber instruments.

/* Dropping singleton observations did not fix the issue.
//bysort panel_id (yearintv): drop if _N==1
*/


/* Commented out because we could not estimate the Arellano-Bond linear dynamic panel-data estimates due to the error discribed above.

 
char degree[omit] 3

char race[omit] 1 
char sex[omit] 1 
char rec_income[omit] 1  
char panel[omit] 1
char wavefe[omit] 2006


	/*Ideological Identification*/
eststo: xi:  xtabond polviews age i.degree i.race i.sex i.rec_income i.panel i.wavefe, lags(1) artests(2)
estimates store polviewsdynamic 

	/*Party Identification*/
eststo: xi:  xtabond rec_partyid age i.degree i.race i.sex i.rec_income i.panel i.wavefe, lags(1) artests(2)
estimates store rec_partyiddynamic 

	/*Government spending too much, too little, or about the right amount on military, armaments and defense.*/
eststo: xi:  xtabond rec_natarms age i.degree i.race i.sex i.rec_income i.panel i.wavefe, lags(1) artests(2)
estimates store rec_natarmsdynamic 


	/*Government spending too much, too little, or about the right amount on welfare.*/
eststo: xi:  xtabond rec_natfare age i.degree i.race i.sex i.rec_income i.panel i.wavefe, lags(1) artests(2)
estimates store rec_natfaredynamic 

	/*Government spending too much, too little, or about the right amount on improving and protecting the environment.*/
eststo: xi:  xtabond rec_natenvir age i.degree i.race i.sex i.rec_income i.panel i.wavefe, lags(1) artests(2)
estimates store rec_natenvirdynamic 

	/*The number of immigrants to America nowadays should be reduced a lot, reduced a little, remain the same as it is, increased a little, or increased a lot*/
eststo: xi:  xtabond rec_letin1a age i.degree i.race i.sex i.rec_income i.panel i.wavefe, lags(1) artests(2)
estimates store rec_letin1adynamic 

	/*combine estimates from six models into one table for paper*/
esttab   polviewsdynamic rec_partyiddynamic rec_natarmsdynamic rec_natfaredynamic rec_natenvirdynamic rec_letin1adynamic using gssdynamic.csv, replace se

*/






/*Rolling correlation*/

/*removing explanatory variables from dataset and reshaping dataset to wide*/

keep panel_id yearintv polviews rec_natarms rec_natfare rec_natenvir rec_letin1a rec_partyid

reshape wide polviews rec_natarms rec_natfare rec_natenvir rec_letin1a rec_partyid, i(panel_id ) j(yearintv)

save "gss_correlations.dta", replace



	/*Ideological Identification*/
asdoc pwcorr polviews*, replace save(polviews_corr.doc)

	/*Government spending too much, too little, or about the right amount on military, armaments and defense.*/
asdoc pwcorr rec_natarms*, replace save(rec_natarms_corr.doc)

	/*Government spending too much, too little, or about the right amount on welfare.*/
asdoc pwcorr rec_natfare*, replace save(rec_natfare_corr.doc)

	/*Government spending too much, too little, or about the right amount on improving and protecting the environment.*/
asdoc pwcorr rec_natenvir*, replace save(rec_natenvir_corr.doc)

	/*The number of immigrants to America nowadays should be reduced a lot, reduced a little, remain the same as it is, increased a little, or increased a lot*/
asdoc pwcorr rec_letin1a*, replace save(rec_letin1a_corr.doc)

	/*Party Identification*/
asdoc pwcorr rec_partyid*, replace save(rec_partyid_corr.doc)


log close
translate comparisons.smcl comparisons.pdf
